var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, n) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, n) {
        e.__proto__ = n;
    } || function(e, n) {
        for (var t in n) n.hasOwnProperty(t) && (e[t] = n[t]);
    })(e, n);
}, function(e, n) {
    function t() {
        this.constructor = e;
    }
    o(e, n), e.prototype = null === n ? Object.create(n) : (t.prototype = n.prototype, 
    new t());
}), a = this && this.__decorate || function(e, n, t, a) {
    var o, l = arguments.length, c = l < 3 ? n : null === a ? a = Object.getOwnPropertyDescriptor(n, t) : a;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(e, n, t, a); else for (var s = e.length - 1; 0 <= s; s--) (o = e[s]) && (c = (l < 3 ? o(c) : 3 < l ? o(n, t, c) : o(n, t)) || c);
    return 3 < l && c && Object.defineProperty(n, t, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("AudioManager"), c = e("GameConfig"), l = e("GameData"), d = e("DataManager"), u = e("WebManager"), p = e("UIManager"), h = e("AdManager"), f = cc._decorator, g = f.ccclass, m = (f.property, 
function(e) {
    function n() {
        return null !== e && e.apply(this, arguments) || this;
    }
    return i(n, e), n.prototype.onLoad = function() {
        (c.GC.isVaild("videoRank") || r.G.isAnonymous) && this.node.destroy();
    }, n.prototype.onClick = function() {
        s.default.getInstance().playAudio("按钮2"), !r.G.isAuth && GA.PA && GA.PA.authorize ? GA.PA.getSetting({
            success: function(e) {
                console.log("getSetting", e), e.authSetting["scope.userInfo"] ? GA.PA.getUserInfo({
                    withCredentials: !1,
                    success: function(e) {
                        console.log("获取用户信息成功", e);
                        e = e.userInfo;
                        l.GD.playerData.nickname = e.nickName, l.GD.playerData.icon = e.avatarUrl, l.GD.playerData.sex = e.gender, 
                        d.default.getInstance().save(), r.G.isAuth = !0, u.default.getInstance().saveRank({
                            data: {
                                userid: GA.Info.uid,
                                level: l.GD.level,
                                nickname: e.nickName,
                                headicon: e.avatarUrl
                            }
                        }), u.default.getInstance().sentLog("点击首页视频排行榜"), p.default.getInstance().loadPnl("video", null, function() {
                            h.default.getInstance().hideAllBanner();
                        });
                    },
                    fail: function(e) {
                        console.log("获取用户信息失败", e);
                    }
                }) : GA.PA.authorize({
                    scope: "scope.userInfo",
                    success: function(e) {
                        console.log("授权成功", e), GA.PA.getUserInfo({
                            withCredentials: !1,
                            success: function(e) {
                                console.log("获取用户信息成功", e);
                                e = e.userInfo;
                                l.GD.playerData.nickname = e.nickName, l.GD.playerData.icon = e.avatarUrl, l.GD.playerData.sex = e.gender, 
                                d.default.getInstance().save(), r.G.isAuth = !0, u.default.getInstance().saveRank({
                                    data: {
                                        userid: GA.Info.uid,
                                        level: l.GD.level,
                                        nickname: e.nickName,
                                        headicon: e.avatarUrl
                                    }
                                }), u.default.getInstance().sentLog("点击首页视频排行榜"), p.default.getInstance().loadPnl("video", null, function() {
                                    h.default.getInstance().hideAllBanner();
                                });
                            },
                            fail: function(e) {
                                console.log("获取用户信息失败", e);
                            }
                        });
                    },
                    fail: function(e) {
                        var n;
                        console.log("授权失败", e), null === (e = null === (n = GA.PA) || void 0 === n ? void 0 : n.showModal) || void 0 === e || e.call(n, {
                            title: "提示",
                            content: "为了更好展示你的视频，使用上传功能需要你先授权",
                            success: function(e) {
                                e.confirm && GA.PA.openSetting({
                                    succes: function(e) {
                                        console.log("openSetting", e), e.authSetting["scope.userInfo"] && GA.PA.getUserInfo({
                                            withCredentials: !1,
                                            success: function(e) {
                                                console.log("获取用户信息成功", e);
                                                e = e.userInfo;
                                                r.G.isAuth = !0, l.GD.playerData.nickname = e.nickName, l.GD.playerData.icon = e.avatarUrl, 
                                                l.GD.playerData.sex = e.gender, d.default.getInstance().save(), u.default.getInstance().saveRank({
                                                    data: {
                                                        userid: GA.Info.uid,
                                                        level: l.GD.level,
                                                        nickname: e.nickName,
                                                        headicon: e.avatarUrl
                                                    }
                                                }), u.default.getInstance().sentLog("点击首页视频排行榜"), p.default.getInstance().loadPnl("video", null, function() {
                                                    h.default.getInstance().hideAllBanner();
                                                });
                                            },
                                            fail: function(e) {
                                                console.log("获取用户信息失败", e);
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }) : (u.default.getInstance().sentLog("点击首页视频排行榜"), p.default.getInstance().loadPnl("video", null, function() {
            h.default.getInstance().hideAllBanner();
        }));
    }, n.prototype.start = function() {}, a([ g ], n);
}(cc.Component));

n.default = m;